import Vue from 'vue'
import Router from 'vue-router'
/* Layout */
import Layout from '@/views/layout/Layout'
// 用户管理路由
import userManage from '@/router/modules/user'
// 课程管理路由
import subjectManage from '@/router/modules/subject'
// 数字资产路由
import classPackage from '@/router/modules/classPackage'
// 运营管理路由
import Operate from '@/router/modules/operate'
// 交易管理路由
import Deal from '@/router/modules/deal'
// 系统
import System from '@/router/modules/system'
// 教育云
import Educate from '@/router/modules/educate'
// 微营销路由
// import Tinysale from '@/router/modules/tinysale'
// 分销
import Distribution from '@/router/modules/distribution'
// 移动端路由
import Mobile from '@/router/modules/mobile'
// 分校管理
import Campus from '@/router/modules/campus'
//组织架构
// import Org from '@/router/modules/org'
// 运营监控
// import Monitor from '@/router/modules/monitor'
// 题库
// import Testing from '@/router/modules/testing'

// in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading;
// detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading

Vue.use(Router);

/**
 * hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
 *                                if not set alwaysShow, only more than one route under the children
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noredirect           if `redirect:noredirect` will no redirect in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    title: 'title'               the name show in subMenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar
    breadcrumb: false            if false, the item will hidden in breadcrumb(default is true)
  }
 **/
export const dynamicRouterMap = [
  userManage,
  subjectManage,
  classPackage,
  Operate,
  Deal,
  Educate,
  Campus,
  Mobile,
  // Tinysale,
  Distribution,
  // Org,
  // Monitor,
  System
  // Testing
];
export const constantRouterMap = [{
  path: '/login',
  component: () =>
    import('@/views/login/index'),
  hidden: true,
  meta: {
    title: '登录'
  }
},
  {
    path: '/404',
    component: () =>
      import('@/views/404'),
    hidden: true,
    meta: {
      title: '404'
    }
  },

  {
    path: '/',
    component: Layout,
    redirect: '/index',
    meta: {
      title: '首页',
      icon: 'dashboard'
    },
    children: [{
      path: 'index',
      name: 'Homepage',
      component: () =>
        import('@/views/homepage/index'),
      meta: {
        title: '首页'
      }
    }]
  },
  userManage,
  subjectManage,
  classPackage,
  Operate,
  Deal,
  Educate,
  Campus,
  Mobile,
  // Tinysale,
  Distribution,
  // Org,
  // Monitor,
  System,
  // Testing,
//
  {
    path: '*',
    redirect: '/404',
    hidden: true
  }
];

const router = new Router({
  routes: constantRouterMap
});
router.beforeEach((to, from, next) => {
  window.document.title = to.meta.title;
  next()
});
export default router
